<template>
  <el-card shadow="never">
    <div slot="header">
      <el-button @click="$router.push({ name: 'monitorIndex' })">返回</el-button>
    </div>
    <el-row :gutter="16">
      <template v-if="list.length > 0">
        <el-col :span="6" v-for="(item,index) in list" :key="index">
          <el-card shadow="never" class="mb20">
            <div slot="header" class="flex" style="justify-content: space-between">
              <el-button
                class="over-word"
                type="text"
                @click="handleItemClick(item)"
              >{{ item.evalItemName}}</el-button>
              <!-- <p class="mb0" style="flex: 1">{{  }}</p> -->
              <span class="red" style="padding-top: 7px">{{ computedType(item) }}</span>
            </div>
            <div class="flex">
              <p style="flex: 1">
                类别：
                <span>{{ item.evalTypeName }}</span>
              </p>
              <h4>{{ item.dateCd }}</h4>
            </div>
            <div style="background: #f1f1f1;">
              <p style="height: 63px">
                主要内容：
                <span>{{ item.evalItemContent }}</span>
              </p>
              <p style="height: 42px">
                评分标准：
                <span>{{ item.standard }}</span>
              </p>
            </div>
            <div class="flex">
              <p class="mb0" style="flex: 1">
                分值：
                <span>{{ item.rewardScroe }}</span>
              </p>
              <p class="mb0">
                结果：
                <span>{{ item.rewardMoney }}</span>
              </p>
            </div>
          </el-card>
        </el-col>
      </template>
      <template v-else>
        <empty-comp />
      </template>
    </el-row>
  </el-card>
</template>

<script>
import { getItemDetails } from '@/api/monitor'
import { getMonitorTime } from '@/utils/util'
export default {
  data() {
    return {
      list: [{ name: 'xm' }],
      row: JSON.parse(this.$route.query.row)
    }
  },
  methods: {
    handleItemClick(item) {
      console.log('item', item)
      this.$router.push({
        path: '/monitor/monitor-evalItemDetail',
        query: { row: JSON.stringify(item) }
      })
    },
    computedType(item) {
      let str = ''
      if (item.rewardMoney) {
        str = item.rewardMoney.charAt(0) + '钱'
      }

      if (item.rewardScroe) {
        str = item.rewardScroe.charAt(0) + '分'
      }
      return str
    }
  },
  async created() {
    let param = getMonitorTime()
    console.log('row', this.row)

    param = { ...param, deptId: this.row.key }
    const res = await getItemDetails(param)
    console.log('科室考评详情', res.data)

    if (res.state === '000000' && res.data.length > 0) {
      this.list = res.data
    } else {
      this.list = []
    }
  }
}
</script>

<style scoped>
.flex {
  display: flex;
}

.over-word {
  max-width: 85%;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>